#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
#include<wait.h>
#include<stdlib.h>
int main()
{
    pid_t id=fork();
    if(id==0)
    {
        //child
        printf("I am child :pid:%d ppid:%d\n",getpid(),getppid());
        execl("./mycmd","mycmd",NULL);   
        exit(1);
    }
    printf("I am father:pid:%d ppid:%d\n",getpid(),getppid());
    int status=0;
    pid_t ret=waitpid(id,&status,0);
    if(ret>0&&WIFEXITED(status))
    {
        printf("wait for id:%d eixt code:%d\n",id,WEXITSTATUS(status));
    }
    else if(ret>0)
    {
        printf("eixt error sign:%d codedump:%d\n",status&0x7F,(status>>7)&1);
    }
    return 0;
}
